package com.bw.image

import android.content.Context
import android.graphics.Color
import android.graphics.drawable.ColorDrawable
import android.graphics.drawable.Drawable
import android.widget.ImageView
import com.bumptech.glide.Glide
import com.bumptech.glide.load.engine.DiskCacheStrategy
import com.bumptech.glide.load.resource.bitmap.CenterCrop

/**
 * 二次封装Glide图片加载器
 */
object GlideImageLoader {

    fun loadImage(context: Context,url:String,imageView: ImageView){
        Glide.with(context)
            .load(url)
            .placeholder(R.drawable.img_loading)
            .error(R.drawable.img_load_error)
            .thumbnail(0.5F)
            .skipMemoryCache(false)
            .diskCacheStrategy(DiskCacheStrategy.RESOURCE)
            .transform(CenterCrop())
            .into(imageView)
    }

    fun loadResImage(context: Context,resId:Int,imageView: ImageView){
        Glide.with(context)
            .load(resId)
            .placeholder(R.drawable.img_loading)
            .error(R.drawable.img_load_error)
            .thumbnail(0.5F)
            .skipMemoryCache(false)
            .diskCacheStrategy(DiskCacheStrategy.RESOURCE)
            .transform(CenterCrop())
            .into(imageView)
    }


}